/*******************************************************************************
 * Copyright (c) 2009 Brian Edginton and Aaron Getz.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Brian Edginton - initial API and implementation
 *     Aaron Getz
 *******************************************************************************/

package org.eclipse.mylyn.internal.eplanner.core;

import java.io.File;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;


/**
 * 
 * @author edge
 *
 */
public class EPlannerRepositoryConnector extends AbstractRepositoryConnector {

	private static final String CLIENT_LABEL = Messages.EPlannerRepositoryConnector_EXTREME_PLANNER_SUPPORTS_3_1_TO_3_2;

	private File repositoryConfigurationCacheFile;
	
	private EPlannerClientManager clientManager;
	
	
	public EPlannerRepositoryConnector() {
		if (EPlannerCorePlugin.getDefault() != null) {
			EPlannerCorePlugin.getDefault().setConnector(this);
			IPath path = EPlannerCorePlugin.getDefault().getRepositoryAttributeCachePath();
			this.repositoryConfigurationCacheFile = path.toFile();
		}
	}
	@SuppressWarnings("unused")
	private final EPlannerTaskAttachmentHandler attachmentHandler = new EPlannerTaskAttachmentHandler(this);
	
	@SuppressWarnings("unused")
	private final EPlannerTaskDataHandler dataHandler = new EPlannerTaskDataHandler(this);
	
	protected EPlannerClientManager clientManger;
	
	
	@Override
	public boolean canCreateNewTask(TaskRepository repository) {
		return true;
	}

	@Override
	public boolean canCreateTaskFromKey(TaskRepository repository) {
		return false;
	}

	@Override
	public String getConnectorKind() {
		return EPlannerCorePlugin.CONNECTOR_KIND;
	}

	@Override
	public String getLabel() {
		return CLIENT_LABEL;
	}

	@Override
	public String getRepositoryUrlFromTaskUrl(String taskFullUrl) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public TaskData getTaskData(TaskRepository taskRepository, String taskId,
			IProgressMonitor monitor) throws CoreException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTaskIdFromTaskUrl(String taskFullUrl) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTaskUrl(String repositoryUrl, String taskId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean hasTaskChanged(TaskRepository taskRepository, ITask task,
			TaskData taskData) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public IStatus performQuery(TaskRepository repository,
			IRepositoryQuery query, TaskDataCollector collector,
			ISynchronizationSession session, IProgressMonitor monitor) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateRepositoryConfiguration(TaskRepository taskRepository,
			IProgressMonitor monitor) throws CoreException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateTaskFromTaskData(TaskRepository taskRepository,
			ITask task, TaskData taskData) {
		// TODO Auto-generated method stub
		
	}
	
	public static boolean hasAttachmentSupport(TaskRepository repository, ITask task) {
		return false;
	}
	
	public EPlannerClientManager getClientManager() {
		if (clientManager == null) {
			clientManager = new EPlannerClientManager();
		}
		return clientManager;
	}
}
